<?php
/**
 * Created by PhpStorm.
 * User: zhangrongxiang
 * Date: 2017/3/27
 * Time: 下午3:43
 */

function my_scandir($dir){
  $files = array();
  if(is_dir($dir)){
    if ($handle = opendir($dir)) {
      while (($file = readdir($handle))!== false) {
        if ($file!="." && $file!="..") {
          if (is_dir($dir."/".$file)) {
            $files[$file] = my_scandir($dir."/".$file);
          } else {
            $files[] = $dir."/".$file;
          }
        }
      }
      closedir($handle);
      return $files;
    }
  }
}


var_dump(my_scandir('.'));